package com.oa.lms.apps.business.user.impl;

import com.oa.lms.apps.business.user.IMailInfoService;
import com.oa.lms.apps.business.user.IPostInfoService;
import com.oa.lms.apps.business.user.IUserInfoService;
import com.oa.lms.apps.dao.user.IUserInfoDao;
import com.oa.lms.apps.entity.user.UserInfoValue;

public class UserInfoServiceImpl implements IUserInfoService {
	
	private IUserInfoDao userInfoDao;
	
	private IMailInfoService mailInfoService;

	private IPostInfoService postInfoService;
	
	private UserInfoValue userInfoValue;

	@Override
	public Integer add(String gender, Integer age, String phone, String address,
			Integer mailId, Integer postId) {
		
		userInfoValue.setGender(gender);
		userInfoValue.setAge(age);
		userInfoValue.setPhone(phone);
		userInfoValue.setAddress(address);
		userInfoValue.setMailInfo(mailInfoService.queryByMailId(mailId));
		userInfoValue.setPostInfo(postInfoService.queryByPostId(postId));
		
		return userInfoDao.add(userInfoValue);
	}

	@Override
	public void modify(Integer infoId, String gender, Integer age, String phone, String address, Integer postId) {
		userInfoValue = this.queryByInfoId(infoId);
		userInfoValue.setGender(gender);
		userInfoValue.setAge(age);
		userInfoValue.setPhone(phone);
		userInfoValue.setAddress(address);
		userInfoValue.setPostInfo(postInfoService.queryByPostId(postId));
		
		userInfoDao.modify(userInfoValue);
		
	}

	@Override
	public UserInfoValue queryByInfoId(Integer infoId) {
		return userInfoDao.queryByInfoId(infoId);
	}


	//Getter and Setter
	
	public IUserInfoDao getUserInfoDao() {
		return userInfoDao;
	}

	public void setUserInfoDao(IUserInfoDao userInfoDao) {
		this.userInfoDao = userInfoDao;
	}

	public IMailInfoService getMailInfoService() {
		return mailInfoService;
	}

	public void setMailInfoService(IMailInfoService mailInfoService) {
		this.mailInfoService = mailInfoService;
	}

	public IPostInfoService getPostInfoService() {
		return postInfoService;
	}

	public void setPostInfoService(IPostInfoService postInfoService) {
		this.postInfoService = postInfoService;
	}

	public UserInfoValue getUserInfoValue() {
		return userInfoValue;
	}

	public void setUserInfoValue(UserInfoValue userInfoValue) {
		this.userInfoValue = userInfoValue;
	}
	
}
